package com.lby.rabbitmq.listener;

import com.lby.rabbitmq.bean.Student;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName TopicListener
 * @Description TODO
 * @Author louby0923
 * @Date 2024/2/2 10:35
 * @Version 1.0
 */
@Component
public class TopicListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "lby.topic.queue1"),
            exchange = @Exchange(name = "lby.topic",type = ExchangeTypes.TOPIC),
            key = "china.#"
    ))
    public void queue1(String massage){
        System.out.println("lby.topic.queue1 = " + massage);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "lby.topic.queue2"),
            exchange = @Exchange(name = "lby.topic",type = ExchangeTypes.TOPIC),
            key = "#.news"
    ))
    public void queue2(Student massage){
        System.out.println("lby.topic.queue2 = " + massage);
    }

}
